<div id="Variables"></div>
<div class="header">
<p>
Next: [[cvs: The CVSROOT%47config configuration file#The CVSROOT/config configuration file|config]], Previous: [[cvs: The history file#The history file|history file]], Up: [[cvs: Reference manual for Administrative files#Reference manual for Administrative files|Administrative files]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>

----

<div id="Expansions-in-administrative-files"></div>
=== Expansions in administrative files ===
<div id="index-Internal-variables"></div>
<div id="index-Variables"></div>

Sometimes in writing an administrative file, you might
want the file to be able to know various things based
on environment <small>CVS</small> is running in.  There are
several mechanisms to do that.

To find the home directory of the user running <small>CVS</small>
(from the <code>HOME</code> environment variable), use
&lsquo;<code>~</code>&rsquo; followed by &lsquo;<code>/</code>&rsquo; or the end of the line.
Likewise for the home directory of <var>user</var>, use
&lsquo;<code>~<var>user</var></code>&rsquo;.  These variables are expanded on
the server machine, and don&rsquo;t get any reasonable
expansion if pserver (see [[cvs: Direct connection with password authentication#Direct connection with password authentication|Password authenticated]])
is in use; therefore user variables (see below) may be
a better choice to customize behavior based on the user
running <small>CVS</small>.

One may want to know about various pieces of
information internal to <small>CVS</small>.  A <small>CVS</small> internal
variable has the syntax <code>$<nowiki>{</nowiki><var>variable</var><nowiki>}</nowiki></code>,
where <var>variable</var> starts with a letter and consists
of alphanumeric characters and &lsquo;<code>_</code>&rsquo;.  If the
character following <var>variable</var> is a
non-alphanumeric character other than &lsquo;<code>_</code>&rsquo;, the
&lsquo;<code><nowiki>{</nowiki></code>&rsquo; and &lsquo;<code><nowiki>}</nowiki></code>&rsquo; can be omitted.  The <small>CVS</small>
internal variables are:

;<code>CVSROOT</code>
<div id="index-CVSROOT_002c-internal-variable"></div>
: This is the absolute path to the current <small>CVS</small> root directory. See [[cvs: The Repository#The Repository|Repository]], for a description of the various ways to specify this, but note that the internal variable contains just the directory and not any of the access method information.

;<code>RCSBIN</code>
<div id="index-RCSBIN_002c-internal-variable"></div>
: In <small>CVS</small> 1.9.18 and older, this specified the directory where <small>CVS</small> was looking for <small>RCS</small> programs.  Because <small>CVS</small> no longer runs <small>RCS</small> programs, specifying this internal variable is now an error.

;<code>CVSEDITOR</code>
<div id="index-CVSEDITOR_002c-internal-variable"></div>
;<code>EDITOR</code>
<div id="index-EDITOR_002c-internal-variable"></div>
;<code>VISUAL</code>
<div id="index-VISUAL_002c-internal-variable"></div>
: These all expand to the same value, which is the editor that <small>CVS</small> is using.  See [[cvs: Global options#Global options|Global options]], for how to specify this.

;<code>USER</code>
<div id="index-USER_002c-internal-variable"></div>
: Username of the user running <small>CVS</small> (on the <small>CVS</small> server machine). When using pserver, this is the user specified in the repository specification which need not be the same as the username the server is running as (see [[cvs: Setting up the server for password authentication#Setting up the server for password authentication|Password authentication server]]). Do not confuse this with the environment variable of the same name.

If you want to pass a value to the administrative files
which the user who is running <small>CVS</small> can specify,
use a user variable.
<div id="index-User-variables"></div>
To expand a user variable, the
administrative file contains
<code>$<nowiki>{</nowiki>=<var>variable</var><nowiki>}</nowiki></code>.  To set a user variable,
specify the global option &lsquo;<code>-s</code>&rsquo; to <small>CVS</small>, with
argument <code><var>variable</var>=<var>value</var></code>.  It may be
particularly useful to specify this option via
&lsquo;<tt>.cvsrc</tt>&rsquo; (see [[cvs: Default options and the ~%47.cvsrc file#Default options and the ~/.cvsrc file|~/.cvsrc]]).

For example, if you want the administrative file to
refer to a test directory you might create a user
variable <code>TESTDIR</code>.  Then if <small>CVS</small> is invoked
as

<div class="example" style="margin-left: 3.2em">
 cvs -s TESTDIR=/work/local/tests
</div>

and the
administrative file contains <code>sh
$<nowiki>{</nowiki>=TESTDIR<nowiki>}</nowiki>/runtests</code>, then that string is expanded
to <code>sh /work/local/tests/runtests</code>.

All other strings containing &lsquo;<code>$</code>&rsquo; are reserved;
there is no way to quote a &lsquo;<code>$</code>&rsquo; character so that
&lsquo;<code>$</code>&rsquo; represents itself.

Environment variables passed to administrative files are:

<div id="index-environment-variables_002c-passed-to-administrative-files"></div>

;<code>CVS_USER</code>
<div id="index-CVS_005fUSER_002c-environment-variable"></div>
: The <small>CVS</small>-specific username provided by the user, if it can be provided (currently just for the pserver access method), and to the empty string otherwise.  (<code>CVS_USER</code> and <code>USER</code> may differ when &lsquo;<tt>$CVSROOT/CVSROOT/passwd</tt>&rsquo; is used to map <small>CVS</small> usernames to system usernames.)

;<code>LOGNAME</code>
<div id="index-LOGNAME_002c-environment-variable"></div>
: The username of the system user.

;<code>USER</code>
<div id="index-USER_002c-environment-variable"></div>
: Same as <code>LOGNAME</code>. Do not confuse this with the internal variable of the same name.


----

<div class="header">
<p>
Next: [[cvs: The CVSROOT%47config configuration file#The CVSROOT/config configuration file|config]], Previous: [[cvs: The history file#The history file|history file]], Up: [[cvs: Reference manual for Administrative files#Reference manual for Administrative files|Administrative files]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>
This document was generated on <i>a sunny day</i> using [http://www.nongnu.org/texi2html/ <i>texi2html</i>].
